<?php
namespace Base\Entity;

use Zend\Stdlib\Hydrator\Aggregate\AggregateHydrator;
use Zend\Stdlib\Hydrator\ClassMethods;

/**
 * @class AbstractEntity
 * 
 * @package Base\Entity
 * @author Diego Wagner
 */
abstract class AbstractEntity extends AggregateHydrator {

	
	/**
	 * @method __construct
	 * @param array $options
	 * Padrão para getter's e setter's
	 */
	public function __construct ( Array $options = array() ) {
		
		$hydrator = new ClassMethods();
		$hydrator->hydrate( $options, $this );
	}
	
	
	
	
	/**
	 * @method toString()
	 * Método padrão para o toArray
	 */
	public function toString( Array $options = array() ) {
		
		//(new Hydrator\ClassMethods())->hydrate( $data, $entity ); PHP 5.4 somente
		$hydrator = new AggregateHydrator();
		$hydrator->hydrate( $options, $this );
	}
	
	
	/**
	 * @method toArray()
	 * Método padrão para o toArray
	 */
	public function toArray() {
		
		$hydrator = new ClassMethods();
		return $hydrator->extract( $this );
	}
}
?>